import http from "@/http";
// 用户列表数据
export const userListApi = (params: IUserListParams): RES<IUserListModel> =>
  http.get("/admin/list", { params });
// 修改用户列表是否启用状态
export const userStatusApi = (id: number, status: number): RES<IUserModel> => http.post(`/admin/updateStatus/${id}?status=${status}`)
// 添加用户
export const addUserApi = (params: IUserModel): RES<IUserModel> =>
  http.post("/admin/register", params);
// 编辑用户
export const editUserApi = (id: number): RES<IUserModel> => http.get(`admin/${id}`)
// 修改用户信息
export const updateUserApi = (params: IUserModel): RES<number> => http.post(`admin/update/${params.id}`, params)
// 获取所有的分配角色列表
export const getRoleListAllApi = (): RES<IRoleModel[]> => http.get("/role/listAll")
// 获取指定账号的分配角色
export const getRolesByUserIdApi = (adminId: number): RES<IRoleModel[]> => http.get(`/admin/role/${adminId}`);
// 修改账号的分配角色
export const updateUserRolesApi = (id: number, ids: number[]): RES<number> => http.post(`/admin/role/update?adminId=${id}&roleIds=${ids.join(",")}`)
// 获取角色列表数据
export const getRolesListApi = (params: IUserListParams): RES<IRoleListModel> =>
  http.get("role/list", { params });
// 修改角色列表是否启用状态
export const roleStatusApi = (id: number, status: number): RES<IUserModel> => http.post(`/role/updateStatus/${id}?status=${status}`)
// 角色列表添加角色
export const addRoleApi = (params: IRoleParamsModel): RES<number> =>
  http.post("/role/create", params);
// 修改角色原本的信息
export const editRolecontentApi = (
  params: IRoleParamsModel,
  id: number
): RES<number> => http.post(`/role/update/${id}`, params);
// 获取角色相关资源
export const getRourceListByRoleIdApi = (roleId: number): RES<IResourceModel[]> => http.get(`/role/listResource/${roleId}`)
// 查询所有后台资源
export const resourceListAllApi = (): RES<IResourceModel[]> => http.get("/resource/listAll")
// 查询所有后台资源分类
export const resourceCategoryApi = (): RES<IResourceCategoryModel[]> => http.get("/resourceCategory/listAll")
// 修改分配资源
export const allocResourceApi = (paramas: allocResourcePramas) =>
  http.post(`/role/allocResource?roleId=${paramas.roleId}&resourceIds=${paramas.resourceIds.join(",")}`
  );
// 请求分配菜单列表
export const treeListApi = (): RES<ItreeMenu[]> => http.get("/menu/treeList");